package org.example.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

public class TestChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();

        //1.增加解码器，主要是为了处理Http
        pipeline.addLast("MyHttpServerCodec", new HttpServerCodec());
        //2.增肌一个自定义的handler
        pipeline.addLast("MyTestServerHandler", new TestServerHandler());
    }
}
